import logging

from cibynet.lib.base import *
from cibynet.lib.auth import authorisation


log = logging.getLogger(__name__)


class RoomsController(AdminController):
  """REST Controller styled on the Atom Publishing Protocol"""

  def index(self, format='html'):
    """GET /rooms: All items in the collection."""
    c.rooms_q = meta.Session.query(Room)
    c.cache_key = "rooms_index"
    return render('/rooms/index.mako')

  def create(self):
    """POST /rooms: Create a new item."""
    pass

  def new(self, format='html'):
    """GET /rooms/new: Form to create a new item."""
    pass

  def update(self, id):
    """PUT /rooms/id: Update an existing item."""
    pass

  def delete(self, id):
    """DELETE /rooms/id: Delete an existing item."""
    pass

  def show(self, id, format='html'):
    """GET /rooms/id: Show a specific item."""
    rooms_q = meta.Session.query(Room)
    try:
      c.room = rooms_q.filter(Room.id == id).one()
    except:
      abort(404)
    else:
      return render('/rooms/detail.mako')

  def edit(self, id, format='html'):
    """GET /rooms/id;edit: Form to edit an existing item."""
    pass
